import request from '@/utils/request'

// base
const base = process.env.VUE_APP_BASE_API6 + '/category'

export function queryTreeList(val) {
  return request({
    url: base + '/queryTreeList',
    method: 'post',
    data: val
  })
}

export function saveOne(val) {
  return request({
    url: base + '/saveOne',
    method: 'post',
    data: val
  })
}

export function deleteOne(val) {
  return request({
    url: base + '/deleteOne',
    method: 'post',
    data: val
  })
}

export function doSort(val) {
  return request({
    url: base + '/doSort',
    method: 'post',
    data: val
  })
}

export function getChannelOptions() {
  return request({
    url: base + '/getChannelOptions',
    method: 'get'
  })
}

export function queryChannelTreeList(val) {
  return request({
    url: base + '/queryChannelTreeList',
    method: 'post',
    data: val
  })
}

export function getAttributeList(params) {
  return request({
    url: base + '/getAttributeList',
    method: 'get',
    params
  })
}

export function getCategoryDataTreeList(val) {
  let uri = ''
  if (val.shopCategoryFlag === 1) {
    uri = '/queryTreeList'
  } else if (val.shopCategoryFlag === 0) {
    uri = '/queryChannelTreeList'
  }
  return request({
    url: base + uri,
    method: 'post',
    data: val
  })
}

export function getAllCategoryType() {
  return request({
    url: base + '/getAllCategoryType',
    method: 'get'
  })
}

export function syncChannleData(channelId) {
  return request({
    url: base + '/syncChannleData?channelId=' + channelId,
    method: 'get'
  })
}

export function publish(val) {
  return request({
    url: base + '/publish',
    method: 'post',
    data: val
  })
}

export function pullJDChannelBrand(val) {
  return request({
    url: base + '/pullJDChannelBrand',
    method: 'post',
    data: val
  })
}
